#include <iostream>
#include <string>
#include <vector>
#include "BinaryTree.h"
using namespace std;

// 100.00 %
class Solution
{
  public:
	vector<string> binaryTreePaths(TreeNode *root)
	{
		vector<string> myV;
		if (!root)
		{
			return myV;
		}
		if (!root->left && !root->right)
		{
			myV.push_back(to_string(root->val));
			return myV;
		}
		vector<string> myLV = binaryTreePaths(root->left);
		vector<string> myRV = binaryTreePaths(root->right);
		for (int i = 0; i < myLV.size(); i++)
		{
			myV.push_back(to_string(root->val) + "->" + myLV[i]);
		}
		for (int i = 0; i < myRV.size(); i++)
		{
			myV.push_back(to_string(root->val) + "->" + myRV[i]);
		}
		return myV;
	}
};

int main()
{
	int arr[] = {1, 2, 4, 0, 0, 5, 0, 0, 3, 6, 0, 0, 7, 0, 0};
	int n = sizeof(arr) / sizeof(arr[0]);
	TreeNode *tree = createBinaryTree(arr, n);
	preorderPrint(tree);
	cout << endl;
	vector<string> myvector = Solution().binaryTreePaths(tree);
	for (int i = 0; i < myvector.size(); i++)
	{
		cout << myvector[i] << endl;
	}
	deleteBinaryTree(tree);
	return 0;
}
